package daoimpl;

import java.sql.PreparedStatement;
import java.sql.ResultSet;

import dao.BaseDao;
import dao.UserDao;
import pojo.User;
public class UserDaoImpl extends BaseDao implements UserDao{

	@Override
	public int login(User user) {
		
		Object[] arr=  {user.getUser(),user.getPsd()};
		String sql ="select * from user where shoujihao=? and mima =?";
		PreparedStatement pstmt =executeQuery(sql,arr);
		try {
			ResultSet rs =  pstmt.executeQuery();
			if (rs.next()) {
			user.setUser2(rs.getString(6));
				return 1;
			}
			else {
				return 0;
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return 0;
	}
	

}
